package com.wcar.store.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wcar.common.entity.Store;
import com.wcar.common.util.OssUtil;
import com.wcar.common.vo.Result;
import com.wcar.store.service.StoreService;
import com.wcar.store.vo.AddressVo;
import com.wcar.store.vo.StoreVo;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @BelongsProject: four-wcar-idea
 * @BelongsPackage: com.wcar.store.controller
 * @Author: 李睢康
 * @CreateTime: 2024-05-28  14:31
 */
@RestController
@RequestMapping("/store")
public class StoreController {
    @Resource
    private StoreService service;
    @PostMapping("/api/selectPageStore")
    public Result<IPage> getAll(@RequestBody StoreVo storeVo){
        return service.getAll(storeVo);
    }
    @PostMapping("/api/uploadFile")
    public Result<String> img(MultipartFile file){
        String s = OssUtil.uploadOss(file);
        return new Result<String>(200,"上传成功",s);
    }
    @PostMapping("/api/insertStore")
    public Result<Integer> insert(@RequestBody Store store){
        return service.insert(store);
    }

    @PostMapping("/api/updateStore")
    public Result<Integer> update(@RequestBody Store store){
        return service.update(store);
    }
    @GetMapping("/api/deleteStore")
    public Result<Integer> delete(Integer storeId){
        return service.delete(storeId);
    }
    @PostMapping("/api/selectDetailStore")
    public Result<List<Store>> getSoreAll(@RequestBody AddressVo address){
        return service.modelGetAll(address);
    }

}
